const crypto = require('crypto');

const fs = require('fs');
 
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
  modulusLength: 2048,
  publicKeyEncoding: {
    type: 'spki',
    format: 'pem',
  },
  privateKeyEncoding: {
    type: 'pkcs8',
    format: 'pem',
    cipher: 'aes-256-cbc',
    passphrase: 'mySecret'
  },
});

// 将私钥写入文件
fs.writeFileSync('./utils/properties/rsa_private_key.pem', privateKey);
 
// 将公钥写入文件
fs.writeFileSync('./utils/properties/rsa_public_key.pem', publicKey);